﻿using Microsoft.EntityFrameworkCore;

namespace QueryData;

internal class 跟踪和非跟踪查询
{
    void MyMethod()
    {
        using (var db = new BasicDbContext())
        {
            db.SubEntities.AsNoTracking()
                .Include(s => s.MainEntity)
                .ToList();

            db.SubEntities.AsNoTrackingWithIdentityResolution()
                .Include(s => s.MainEntity)
                .ToList();

            db.SubEntities.AsTracking()
                .Include(s => s.MainEntity)
                .ToList();

        }
    }
}
